package com.gan.simple_init.common.exception;


import com.gan.simple_init.common.base.ResponseErrorEnum;

/**
 * 自定义异常类
 *
 */
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    private final int code;

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message) {
        super(message);
        this.code = 50000;
    }

    public BusinessException(ResponseErrorEnum e) {
        super(e.getMessage());
        this.code = e.getCode();
    }

    public BusinessException(ResponseErrorEnum e, String message) {
        super(message);
        this.code = e.getCode();
    }

    public int getCode() {
        return code;
    }
}
